{template 'common/header'}
<ul class="nav nav-tabs">
	<li {if $foo == 'post'}class="active"{/if}><a href="{php echo $this->createWebUrl('category', array('foo' => 'post'))}">添加分类</a></li>
	<li {if $foo == 'display'}class="active"{/if}><a href="{php echo $this->createWebUrl('category', array('foo' => 'display'))}">管理分类</a></li>
</ul>
{if $foo == 'post'}
<div class="main">
	<form action="" method="post" class="form-horizontal form" enctype="multipart/form-data">
	<input type="hidden" name="parentid" value="{$parent['id']}" />
		<h4>分类详细设置</h4>
		<table class="tb">
			{if !empty($category)}
			<tr>
				<th><label for="">访问地址</label></th>
				<td>
					<a href="{php echo $this->createMobileUrl('list', array('cid' => $category['id'], 'weid' => $_W['weid']))}" target="_blank">{php echo $this->createMobileUrl('list', array('cid' => $category['id'], 'weid' => $_W['weid']))}</a>
					<span class="help-block">您可以根据此地址，添加回复规则，设置访问。</span>
				</td>
			</tr>
			{/if}
			<tr>
				<th></th>
				<td></td>
			</tr>
			{if !empty($parentid)}
			<tr>
				<th><label for="">上级分类</label></th>
				<td>
					{$parent['name']}
				</td>
			</tr>
			{/if}
			<tr>
				<th><label for="">排序</label></th>
				<td>
					<input type="text" name="displayorder" class="span6" value="{$category['displayorder']}" />
				</td>
			</tr>
			<tr>
				<th><label for="">分类名称</label></th>
				<td>
					<input type="text" name="cname" class="span6" value="{$category['name']}" />
				</td>
			</tr>
			<tr>
				<th><label for="">分类描述</label></th>
				<td>
					<textarea name="description" class="span6" cols="70">{$category['description']}</textarea>
				</td>
			</tr>
		</table>
		<table class="tb">
		<tr>
			<th></th>
			<td>
				<input name="submit" type="submit" value="提交" class="btn btn-primary span3">
				<input type="hidden" name="token" value="{$_W['token']}" />
			</td>
		</tr>
		</table>
	</form>
</div>
{elseif $foo == 'display'}
<div class="main">
	<div class="category">
		<form action="" method="post" onsubmit="return formcheck(this)">
		<table class="table table-hover">
			<thead>
				<tr>
					<th style="width:10px;"></th>
					<th style="width:60px;">显示顺序</th>
					<th>分类名称</th>
					<th>链接</th>
					<th style="width:80px;">设为栏目</th>
					<th style="width:120px;">操作</th>
				</tr>
			</thead>
			<tbody>
			{loop $category $row}
				<tr>
					<td>{if count($children[$row['id']]) > 0}<a href="javascript:;"><i class="icon-chevron-down"></i></a>{/if}</td>
					<td><input type="text" class="span1" name="displayorder[{$row['id']}]" value="{$row['displayorder']}"></td>
					<td><div class="type-parent">{$row['name']}&nbsp;&nbsp;{if empty($row['parentid'])}<a href="{php echo $this->createWebUrl('category', array('foo' => 'post', 'parentid' => $row['id']))}" title="添加子分类"><i class="icon-plus-sign-alt"></i></a>{/if}</div></td>
					<td><input type="text" class="span3" value="{php echo $this->createMobileUrl('list', array('cid' => $row['id'], 'weid' => $_W['weid']))}"></td>
					<td>{php echo $row['nid'] ? '是' : '否'}</td>
					<td>
						<a href="{php echo $this->createWebUrl('article', array('foo' => 'post', 'pcate' => $row['id']))}" title="添加文章" class="btn btn-small"><i class="icon-plus"></i></a>
						<a href="{php echo $this->createWebUrl('category', array('foo' => 'post', 'id' => $row['id']))}" title="编辑" class="btn btn-small"><i class="icon-edit"></i></a>
						<a href="{php echo $this->createWebUrl('category', array('foo' => 'delete', 'name' => 'site', 'id' => $row['id']))}" onclick="return confirm('确认删除此分类吗？');return false;" title="删除" class="btn btn-small"><i class="icon-remove"></i></a>
					</td>
				</tr>
				{loop $children[$row['id']] $row}
				<tr>
					<td></td>
					<td><input type="text" class="span1" name="displayorder[{$row['id']}]" value="{$row['displayorder']}"></td>
					<td><div class="type-child">{$row['name']}&nbsp;&nbsp;{if empty($row['parentid'])}<a href="{php echo $this->createWebUrl('category', array('foo' => 'post', 'parentid' => $row['id']))}"><i class="icon-plus-sign-alt" title="添加子分类"><i class="icon-plus-sign-alt"></i></a>{/if}</div></td>
					<td><input type="text" class="span3" value="{php echo $this->createMobileUrl('list', array('cid' => $row['id'], 'weid' => $_W['weid']))}"></td>
					<td>{php echo $row['enabled'] ? '是' : '否'}</td>
					<td>
						<a href="{php echo $this->createWebUrl('article', array('foo' => 'post', 'pcate' => $row['parentid'], 'ccate' => $row['id']))}" title="添加文章" class="btn btn-small"><i class="icon-plus"></i></a>
						<a href="{php echo $this->createWebUrl('category', array('foo' => 'post', 'id' => $row['id']))}" title="编辑" class="btn btn-small"><i class="icon-edit"></i></a>
						<a href="{php echo $this->createWebUrl('category', array('foo' => 'delete', 'id' => $row['id']))}" onclick="return confirm('确认删除此分类吗？');return false;" title="删除" class="btn btn-small"><i class="icon-remove"></i></a>
				</td>
				</tr>
				{/loop}
			{/loop}
				<tr>
					<td></td>
					<td colspan="5">
						<a href="{php echo $this->createWebUrl('category', array('foo' => 'post'))}"><i class="icon-plus-sign-alt"></i> 添加新分类</a>
					</td>
				</tr>
				<tr>
					<td></td>
					<td colspan="5">
						<input name="submit" type="submit" class="btn btn-primary" value="提交">
						<input type="hidden" name="token" value="{$_W['token']}" />
					</td>
				</tr>
			</tbody>
		</table>
		</form>
	</div>
</div>
{/if}
{template 'common/footer'}
